import React from 'react';
import { connect } from 'dva';
import TreeComponent from '../../components/Common/Tree/Tree';

function Tree({ dispatch, ...props }) {
  const treeProps = {
    ...props,
    onFormData: getFormData, /* 根据左侧树类别查询 */
  };

  function getFormData(componentName, dataUrl, value, fastbFilter) {
    dispatch({
      type: 'mergeTable/getFormData',
      payload: {
        componentName, dataUrl, value, fastbFilter,
      },
    });
  }

  return (
    <TreeComponent {...treeProps} />
  );
}

export default connect(({ app }) =>
  ({ app }))(Tree);
